const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin')
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const VueSSRClientPlugin = require('vue-server-renderer/client-plugin')

module.exports = {
    entry: path.resolve(__dirname,'../src/entry-client.js'),
    output: {
        path: path.resolve(__dirname, '../dist'),
        filename: 'index.js'
    },
    module: {
        rules: [{
                test: /\.css$/i,
                use: ['vue-style-loader', 'css-loader']
            },
            {
                test: /\.vue$/i,
                use: 'vue-loader'
            },
            {
                test: /\.(js|jsx)$/i,
                exclude: /node_modules/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env']
                    }
                }
            },
            {
                test: /\.(png|svg|jpe?g)$/,
                use: [
                  {
                    loader: 'url-loader',
                    options: {
                    esModule: false,
                      limit: 8192,
                      name: 'images/[name].[hash:7].[ext]',
                      publicPath: './'
                    }
                  }
                ]
              },
              {
                test: /\.(woff|woff2|eot|ttf|otf)$/,
                loader: 'file-loader'
              }
        ],
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: './src/index.html'
        }),
        new VueLoaderPlugin(),
        new VueSSRClientPlugin()
    ]
};